﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="ChoiceOrgPers_Bottom.aspx.cs" Inherits="Common_ChoiceOrgPers_Bottom" %>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
  <title>无标题页</title>
    <link href="../CSS/css.CSS" type="text/css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
    <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td style ="height :90%;">
        <asp:TextBox ID="POPNameCol" TextMode="multiLine" runat ="server" Rows ="5" Columns ="60"></asp:TextBox>
        <input type="hidden" id="POPIDCol" runat ="server"  /> 
        </td>
      </tr>
      <tr>
       <td align ="center" >
         <input name="Save"  id="Save" type="button" class="button02" onclick="tijiao()"  value="确定" runat ="server" />  
         <input name="Close"  id="Close" type="button" class="button02" onclick="window.close()"  value="取消" runat ="server" />  </td>
    </tr>
    </table> 
    
<input type="hidden" id="Hcode" runat ="server"  />
<input type="hidden" id="HPageID" runat ="server"  />
<input type="hidden" id="HOrgType" runat ="server"  />
<input type="hidden" id="OrgIDInfo" runat ="server"  />
<input type="hidden" id="OrgNameInfo" runat ="server"  />
<input type="hidden" id="PersNameInfo" runat ="server"  /> 
<input type="hidden" id="PersIDInfo" runat ="server"  /> 

    </form>
    
    <script language ="javascript" type ="text/javascript" >
    var sData = dialogArguments;
    var sPageID = form1.HPageID.value;
    
    var sPOPIDCol   = eval("sData.form1.HChoiceID_"+sPageID+".value");
    var sPOPNameCol = eval("sData.form1.ChoiceName_"+sPageID+".value");
    
    var aPOPIDCol = "";
    var aPOPNameCol = "";
    var err;
    try
    {        
        aPOPIDCol   = sPOPIDCol.split('^');
        aPOPNameCol = sPOPNameCol.split('^'); 
    }
    catch(err)
    {
        aPOPIDCol ="";  
        aPOPNameCol = "";      
    }
    
    if(aPOPIDCol.length == "3")
    {
        form1.POPIDCol.value   = aPOPIDCol[1] +"^"+ aPOPIDCol[2] ;
        form1.POPNameCol.value = aPOPNameCol[0] +"^"+ aPOPNameCol[1] ;
    }
    else
    {
        form1.POPIDCol.value = "";
        form1.POPNameCol.value = "";
    }
    //alert(form1.POPIDCol.value);      
  
    function tijiao()
      {
        if((form1.OrgIDInfo.value == "" || form1.OrgIDInfo.value == null) && (form1.PersIDInfo.value == "" || form1.PersIDInfo.value == null))
        {
           var obj = dialogArguments;
           var sChoiceID = form1.HPageID.value ;
           var ChoiceNameInfo = "\"\"";
           var ChoiceIDInfo   = "\"\"";
           obj.sChoiceID = sChoiceID;
           obj.ChoiceNameInfo  = ChoiceNameInfo;
           obj.ChoiceIDInfo    = ChoiceIDInfo;
           window.returnValue  = obj;
           window.close();
        }
        else
        {
            var obj = dialogArguments;
            var iOrgNum = 0 ;
            var iPersNum = 0 ;
            var OrgNum = form1.OrgIDInfo.value.split(',');   //已选的部门ID的个数
            var PersNum = form1.PersIDInfo.value.split(',');   //已选的人员ID的个数
            if(form1.OrgIDInfo.value != "")
            {
                iOrgNum = OrgNum.length;
            }
            if(form1.PersIDInfo.value !="")
            {
                iPersNum = PersNum.length;
            }      
            
            var sChoiceID = form1.HPageID.value ;
            
            var AllowNum = obj.iChoicePersNumber; //eval("obj.iChoicePoNumber"+sChoiceID);// 
            if(AllowNum!="0")
            {
                if((iOrgNum*1+iPersNum*1)>AllowNum)
                {
                    alert("对不起,你选择的信息已超过"+AllowNum+"个");
                    return;
                }
            } 
            
            var ChoiceNameInfo = "\"" + form1.OrgNameInfo.value +"^"+ form1.PersNameInfo.value + "\"" ;
            var ChoiceIDInfo = "\"" +form1.HPageID.value +"^"+ form1.OrgIDInfo.value +"^"+ form1.PersIDInfo.value + "\"" ;   
            obj.sChoiceID = sChoiceID;
            obj.ChoiceNameInfo = ChoiceNameInfo;
            obj.ChoiceIDInfo = ChoiceIDInfo;
            window.returnValue = obj;
            window.close();
        }
     }     
     </script>
</body>
</html>
